package org.summer.lawyer.controller.wx;


import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.util.StrUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.summer.common.core.domain.R;
import org.summer.lawyer.domain.bo.sysregion.SysRegionBo;
import org.summer.lawyer.service.ISysRegionService;

import java.util.List;

/**
 * 行政区域信息
 *
 * @author summer
 * @date 2024-06-28
 */
@Tag(name = "微信小程序行政区域信息相关接口", description = "行政区域信息相关接口")
@SaIgnore
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/wx/region")
public class WxRegionController {

    private final ISysRegionService sysRegionService;

    @Operation(summary = "获取全国行政区域树", description = "获取全国行政区域树")
    @GetMapping("/regionTree")
    public R<List<Tree<String>>> regionTree(SysRegionBo bo){
        //SysRegionBo bo = new SysRegionBo();
        //上海行政区
       // bo.setPid("14191215310917");
        if(StrUtil.isBlank(bo.getPid())){
            bo.setPid("0");
        }
        bo.setRegionLevel(2L);
        return R.ok(sysRegionService.selectRegionTreeList(bo));
    }
}
